# -*- coding: utf-8 -*-
# coding=utf-8
from flask import request, make_response
from flaskController.Main import app
from tiffHandleAgent.tiffDo.TiffDo import tiffDo


# 根据请求参数返回处理完成的tiff图形处理完成的postgres表名
@app.route('/tiffHandle',methods=['POST'])
def tiffHandle():
    # response=None
    if (request.content_type == 'application/json'):
         if hasattr(request, 'args'):
            tiffPath = request.args['tiffPath']
            tiffName = request.args['tiffName']
            pgSchemaName = request.args['schemaName']
         elif hasattr(request, 'json'):
            tiffPath = request.json['tiffPath']
            tiffName = request.json['tiffName']
            pgSchemaName = request.json['schemaName']
    else:
        tiffPath = request.json['tiffPath']
        tiffName = request.json['tiffName']
        pgSchemaName = request.json['schemaName']
    data = tiffPath + tiffName + pgSchemaName
    data=tiffDo(data)
    response = make_response(data)
    response.headers['Accept-Ranges'] = 'bytes'
    response.headers['Access-Control-Allow-Origin'] = '*'
    response.headers['Content-Type'] = 'application/json'

    return data